package com.mcptt.config.user.profile.sub;

import java.util.List;

import org.jdom.Element;
import org.jdom.JDOMException;

import com.cloudptt.api.product.log.Log;
import com.mcptt.config.user.profile.sub.sub.Rule;


public class Ruleset {
	public static final String Name = "ruleset";
	public static final String Namespace_Cp = "cp";
	
	private Rule rule = null;
	
	public void parse(Element elem) throws JDOMException
	{
		if(elem == null)
		{
			return;
		}
		List<Element> list = elem.getChildren();//��ø��ڵ���ӽڵ�  
		for(Element subElem:list) 
		{
			String name = subElem.getName();
			Log.debug(this.getClass(), "name = " + name);
			
			if(name == null
					|| name.length() <= 0)
			{
				return;
			}
			
			if(name.equals(Rule.Name))
			{
				rule = new Rule();
				rule.parse(subElem);
			}
		}  
	}
	
	public String toString()
	{
		StringBuffer strBuf = new StringBuffer("\r\n");
		strBuf.append("<").append(Namespace_Cp).append(":").append(Name).append(">").append("\r\n");
		
		strBuf.append(rule);
		
		strBuf.append("</").append(Namespace_Cp).append(":").append(Name).append(">").append("\r\n");

		return strBuf.toString();
	}
}
